package com.xinruke.hostels.reservation.user.controller;

import com.xinruke.hostels.common.controller.BaseController;
import com.xinruke.hostels.common.vo.ResultVO;
import com.xinruke.hostels.reservation.user.interfaces.dto.RegisterDTO;
import com.xinruke.hostels.reservation.user.service.RegisterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @ClassName RegisterController
 * @CreateDate 2019/6/11
 * @Author FengXinQiang
 * @Version V1.0.0.0
 * @Decription 用户注册
 */
@RestController
@RequestMapping("register")
@Api(tags = "用户注册")
public class RegisterController extends BaseController {
    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    RegisterService registerService;

    @PostMapping("userRegister")
    @ApiOperation("注册")
    public ResultVO userRegister(@RequestBody @Valid RegisterDTO registerDTO) {
        ResultVO resultVO = ResultVO.fail();

        try {
            resultVO = registerService.userRegister(registerDTO);
        } catch (Exception e) {
            logger.error("系统异常", e);
        }

        return resultVO;
    }

}
